﻿using System.Windows;
using System.Windows.Controls;
using KinonekoSoftware.Studio.Models.Shells;

namespace KinonekoSoftware.Studio.Views.Settings
{
    public partial class SettingAboutView : UserControl
    {
        public SettingAboutView()
        {
            InitializeComponent();

            //
            //
            ToggleTracer.IsChecked = Platform.IsTrace();
        }
        
        private void Button_OnOpenTracerWindow(object sender, RoutedEventArgs e)
        {
            TracerWindow debugOutputTarget = null;

            foreach (Window window in Application.Current.Windows)
            {
                // ReSharper disable once MergeCastWithTypeCheck
                if (window is TracerWindow)
                {
                    debugOutputTarget = (TracerWindow)window;
                }
            }
            

            if (debugOutputTarget is null)
            {
                debugOutputTarget = new TracerWindow();
                debugOutputTarget.Show();
            }
            else
            {
                debugOutputTarget.WindowState = WindowState.Normal;
                debugOutputTarget.Width       = 640;
                debugOutputTarget.Height      = 480;
                debugOutputTarget.Left        = 0;
                debugOutputTarget.Top        = 0;
            }
        }
        
        
        private void Button_ToggleTracer(object sender, RoutedEventArgs e)
        {
            var setting = Ioc.Get<JuXiaoYouSetting>();
            setting.EnableDebug = !setting.EnableDebug;
            Platform.SaveSetting(setting);
        }
    }
}